﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace TestProject
{
    class TestMail
    {

        public static void SendMailTest()
        {
            Console.WriteLine("Lancement de TestMail.SendMailTest");
            Console.WriteLine();
            Console.WriteLine(" *****----- Preparation du mail -----***** ");

            MailAddress sender =  new MailAddress("gipi@tourisme.gouv.qc.ca","Test Display Name Sender");
            MailAddress to =   new MailAddress("dominic.richard@tourisme.gouv.qc.ca");
            
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress("gipi@tourisme.gouv.qc.ca","Nice Name");
            msg.Sender = sender;
            msg.To.Add(to);
            msg.Subject = "Test Mail";
            msg.Body = "Ceci est un test t'entends?? ";
            msg.IsBodyHtml = true;
            

            Console.WriteLine("=== MAIL ===");
            Console.WriteLine(string.Format("From : {0} - {1}",msg.From.DisplayName, msg.From.Address));
            //Console.WriteLine(string.Format("Sender : {0} - {1}", msg.Sender.DisplayName, msg.Sender.Address));
            Console.WriteLine(string.Format("To : {0} - {1}", msg.To[0].DisplayName, msg.To[0].Address));
            Console.WriteLine(string.Format("Subject : {0}", msg.Subject));
            Console.WriteLine(string.Format("Body : {0}", msg.Body));

            SmtpClient client = new SmtpClient();
            // info du machine.config
            //<network host="sv-smtp-1.tourisme.gouv.qc.ca" port="5792"/>
            client.Host = "sv-smtp-1.tourisme.gouv.qc.ca";
            client.Port = 5792;

            Console.WriteLine("Client Host : {0}", client.Host);
            Console.WriteLine("Client Port : {0}", client.Port);
            Console.WriteLine("Delivery Method : {0}", client.DeliveryMethod.ToString());


            client.Send(msg);
            
        }
    }
}
